package cars;

import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: mac
 * Date: 2022-11-23
 * Time: 22:09
 */
//CarList存储轿车
public class CarList extends VehicleList{
    LinkedList<Car> list;
    public CarList() {
        list = new LinkedList<>();
        list.add(new Car("京NY28588","宝马","X6",800));
        list.add(new Car("京CNY3284","宝马","550i",600));
        list.add(new Car("京NT37465","别克","林荫大道",300));
        list.add(new Car("京NY28588","别克","GL8",600));
    }
    public void printf(String velName){
        int number = 1;
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).brand.compareTo(velName) == 0){
                System.out.print(number + "." + list.get(i).type + "   ");
                number++;
            }
        }
        System.out.println();
    }
    public Car find(String data1, String data2){
        for (int i = 0; i < list.size(); i++) {
            Car car = list.get(i);
            if (car.brand.compareTo(data1) == 0 && car.type.compareTo(data2) == 0){
                System.out.println(car.vehicleld);
                return car;
            }
        }
        return null;
    }
    public double getPerRent(Vehicle car, int days){
        if (days > 7 && days < 30){
            return (car.perRent * days * 0.9);
        }else if (days > 30 && days < 150){
            return car.perRent * days * 0.8;
        }else if (days > 150){
            return car.perRent * days * 0.7;
        }else{
            return car.perRent * days;
        }
    }
    public int del(String data1, String data2){
        for (int i = 0; i < list.size(); i++) {
            Car vehicle = list.get(i);
            if (vehicle.brand.compareTo(data1) == 0 && vehicle.type.compareTo(data2) == 0){
                return i;
            }
        }
        return -1;
    }
}
